BleManager Class Reference
| Inherits from | NSObject |
|---|---|
| Conforms to | CBCentralManagerDelegate CBPeripheralDelegate |
| Declared in | BleManager.h BleManager.m |
blockOnCentralManagerDidUpdateState
设备状态改变的block Block of device state changes
@property (nonatomic, copy) CentralManagerDidUpdateStateBlock blockOnCentralManagerDidUpdateStateDiscussion
设备状态改变的block Block of device state changes
Declared In
BleManager.h
blockOnDisconnect
断开设备连接的block Block that disconnects the device
@property (nonatomic, copy) DisconnectBlock blockOnDisconnectDiscussion
断开设备连接的block Block that disconnects the device
Declared In
BleManager.h
readTotalCallback
所有数据返回都会调用这个block This block is going to be called when all the data comes back
@property (nonatomic, copy) ReadDataBlock readTotalCallbackDiscussion
所有数据返回都会调用这个block This block is going to be called when all the data comes back
Declared In
BleManager.h
filterOnDiscoverPeripherals
发现设备名字规则 Discover the device name rule
@property (nonatomic, copy) FilterOnDiscoverPeripherals filterOnDiscoverPeripheralsDiscussion
发现设备名字规则 Discover the device name rule
Declared In
BleManager.h
bleOptions
设置蓝牙连接属性 Sets Bluetooth connection properties
@property (nonatomic, strong) BleOptions *bleOptionsDiscussion
设置蓝牙连接属性 Sets Bluetooth connection properties
Declared In
BleManager.h
isConnected
是否已经连上 Whether it’s already connected
@property (nonatomic, assign) BOOL isConnectedDiscussion
是否已经连上 Whether it’s already connected
Declared In
BleManager.h
isScanning
是否正在扫描 Whether you are scanning
@property (nonatomic, assign) BOOL isScanningDiscussion
是否正在扫描 Whether you are scanning
Declared In
BleManager.h
isSending
是否正在发送 Whether it is being sent
@property (nonatomic, assign) BOOL isSendingDiscussion
是否正在发送 Whether it is being sent
Declared In
BleManager.h
– scanPeripheralsWithBlock:
开启扫描设备 Turn on scanning device
- (void)scanPeripheralsWithBlock:(nullable DiscoverPeripheralsBlock)blockOnDiscoverPeripheralsParameters
blockOnDiscoverPeripherals |
发现设备的回调 Discover the device’s callback |
|---|
Discussion
开启扫描设备 Turn on scanning device
Declared In
BleManager.h
– cancelScan
取消扫描 Cancel the scan
- (void)cancelScanDiscussion
取消扫描 Cancel the scan
Declared In
BleManager.h
– connectToPeripheral:withConnected:withFail:withState:
连接设备 Connected device
- (void)connectToPeripheral:(nullable CBPeripheral *)peripheral withConnected:(nullable ConnectedPeripheralBlock)blockOnConnectedPeripheral withFail:(nullable FailToConnectBlock)blockOnFailToConnect withState:(nullable ConnectPeripheralStateBlock)blockOnConnectPeripheralStateParameters
peripheral |
需要连接的设备 Devices that need to be connected |
|---|---|
blockOnConnectedPeripheral |
连接成功的回调 A callback for successful connection |
blockOnFailToConnect |
连接失败的回调 Callback for connection failure |
Discussion
连接设备 Connected device
Declared In
BleManager.h
– cancelPeripheralConnection:
断开已连接的设备 Disconnect the connected device
- (void)cancelPeripheralConnection:(nullable CBPeripheral *)peripheralParameters
peripheral |
传入已连接的设备 Passing in the connected device |
|---|
Discussion
断开已连接的设备 Disconnect the connected device
Declared In
BleManager.h
– getConnectedDevice
获取当前连接的设备 Gets the currently connected device
- (CBPeripheral *)getConnectedDeviceReturn Value
CBPeripheral 已连接的设备 Connected device
Discussion
获取当前连接的设备 Gets the currently connected device
Declared In
BleManager.h
– write:progress:receCallBack:
往连接设备中写入数据 Writes data to the connected device
- (void)write:(NSData *_Nullable)data progress:(nullable WriteProgressBlock)progress receCallBack:(nullable ReadDataBlock)callBackParameters
data |
写入的数据 Written data |
|---|---|
progress |
写入数据的进度 The progress of writing data |
callBack |
设备返回的数据 Data returned by the device |
Discussion
往连接设备中写入数据 Writes data to the connected device
Declared In
BleManager.h
– cancelSendData
取消写入数据 Unwrite data
- (void)cancelSendDataDiscussion
取消写入数据 Unwrite data
Declared In
BleManager.h
– getCentralManagerState
获取注设备状态 Gets the status of injection device
- (CBManagerState)getCentralManagerStateReturn Value
设备状态 Equipment state
Discussion
获取注设备状态 Gets the status of injection device
Declared In
BleManager.h